package org.scirp.ijmis.dao.personpaper.impl;

import java.util.List;

import org.scirp.ijmis.dao.base.impl.BaseDAOImpl;
import org.scirp.ijmis.dao.personpaper.IPublicationDAO;
import org.scirp.ijmis.po.personpaper.Publication;

public class PublicationDAOImpl extends BaseDAOImpl<Publication> implements IPublicationDAO {

	private static final String className = PublicationDAOImpl.class.toString();

	public List<Publication> selectAll() {

		String hql = "from Publication order by pid desc";
		return super.ExecuteQuery(hql, className + "-->selectAll");
	}

	public Long countObject() {
		return super.countObject(className + "-->countObject");
	}

	public List<Publication> selectByJournalId(Long journalId) {
		String hql = "from Publication where journalId=" + journalId + " order by pid desc";
		return super.ExecuteQuery(hql, className + "-->selectByJournalId(Long journalId)");
	}

	public List<Publication> selectPublication(String volume, String number, String month, String year, Long journalId, Long pid) {
		String hql = "from Publication where volume='" + volume + "' and publicationNumber='" + number + "' and publicationMonth='" + month + "' and publicationYear='" + year + "' and journalId=" + journalId + " and pid !=" + pid;
		return super.select(hql, 0, 0, className + "-->selectPublication(String volume,String number,String month,String year,Long journalId,Long pid)");
	}

	public Publication selectById(Object id) {

		return (Publication) super.selectById(id, className + "-->selectById");
	}

	public long savePublication(Publication entity) {
		return super.saveObject(entity, className + "-->savePublication(Publication entity)");
	}

	public boolean updatePublication(Publication entity) {
		return super.updateObject(entity, className + "-->updatePublication(Publication entity)");
	}

	public boolean deletePublicationByPublicationId(Long publicationId) {
		String hql = "delete Publication where pid=" + publicationId;
		return super.ExecuteNonQuery(hql, null, className + "-->deletePublicationByPublicationId(Long publicationId)");
	}

	public Publication selectPublicationByPaperId(Long paperId) {
		String hql = "from Publication where paperId=" + paperId;
		return (Publication) super.selectSingle(hql, null, className + "-->selectPublicationByPaperId(Long paperId)");

	}

}
